<template>
  <div class="page-container">
    <top-navigation @toggleFullscreen="toggleFullscreen" />
    <div class="main-content">
      <div class="monitor-grid">
        <div class="monitor-card">
          <div class="card-header">
            <span class="title">水位监测</span>
            <span class="value">262.25<span class="unit">m</span></span>
          </div>
          <div class="chart-container">
            <!-- Chart will be added here -->
          </div>
        </div>

        <div class="monitor-card">
          <div class="card-header">
            <span class="title">流量监测</span>
            <span class="value">1390<span class="unit">m³/s</span></span>
          </div>
          <div class="chart-container">
            <!-- Chart will be added here -->
          </div>
        </div>

        <div class="monitor-card">
          <div class="card-header">
            <span class="title">机组运行状态</span>
          </div>
          <div class="unit-grid">
            <div class="unit-row">
              <span class="unit-name">1号机组</span>
              <span class="unit-status">升档中</span>
              <span class="unit-power">150.93 MW</span>
            </div>
            <div class="unit-row">
              <span class="unit-name">2号机组</span>
              <span class="unit-status">升档中</span>
              <span class="unit-power">279.18 MW</span>
            </div>
            <div class="unit-row">
              <span class="unit-name">3号机组</span>
              <span class="unit-status">升档中</span>
              <span class="unit-power">199.96 MW</span>
            </div>
            <div class="unit-row">
              <span class="unit-name">4号机组</span>
              <span class="unit-status">升档中</span>
              <span class="unit-power">142.27 MW</span>
            </div>
          </div>
        </div>

        <div class="monitor-card">
          <div class="card-header">
            <span class="title">上网电量</span>
          </div>
          <div class="power-grid">
            <div class="power-row">
              <span class="station">小浪底</span>
              <div class="power-values">
                <span class="current">7.92</span>
                <span class="separator">/</span>
                <span>58.32</span>
                <span class="unit">亿千瓦时</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import TopNavigation from '@/components/TopNavigation.vue'

const isFullscreen = ref(false)

const toggleFullscreen = () => {
  if (!document.fullscreenElement) {
    document.documentElement.requestFullscreen()
    isFullscreen.value = true
  } else {
    document.exitFullscreen()
    isFullscreen.value = false
  }
}
</script>

<style lang="scss" scoped>
.page-container {
  width: 100%;
  height: 100vh;
  background: #1a1f3d;
  color: #fff;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: 20px;
  overflow: auto;
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  height: 100%;
}

.monitor-card {
  background: rgba(13, 19, 35);
  border: 1px solid rgba(63, 158, 255, 0.1);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;

  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(63, 158, 255, 0.1);

    .title {
      font-size: 18px;
      color: rgba(255, 255, 255, 0.9);
      font-weight: 500;
    }

    .value {
      font-size: 24px;
      color: #3f9eff;
      font-weight: bold;

      .unit {
        font-size: 14px;
        opacity: 0.8;
        margin-left: 4px;
      }
    }
  }

  .chart-container {
    flex: 1;
    min-height: 200px;
  }
}

.unit-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.unit-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: 12px;
  background: rgba(63, 158, 255, 0.05);
  border-radius: 4px;
  transition: all 0.3s;

  &:hover {
    background: rgba(63, 158, 255, 0.1);
  }

  .unit-name {
    color: rgba(255, 255, 255, 0.8);
  }

  .unit-status {
    color: #67c23a;
    text-align: center;
    padding: 2px 8px;
    background: rgba(103, 194, 58, 0.1);
    border-radius: 2px;
  }

  .unit-power {
    color: #3f9eff;
    text-align: right;
    font-weight: 500;
  }
}

.power-grid {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.power-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: rgba(63, 158, 255, 0.05);
  border-radius: 4px;

  .station {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
  }

  .power-values {
    font-size: 20px;
    color: #3f9eff;
    font-weight: 500;

    .separator {
      margin: 0 8px;
      opacity: 0.5;
    }

    .unit {
      font-size: 14px;
      opacity: 0.8;
      margin-left: 6px;
    }

    .current {
      color: #67c23a;
    }
  }
}
</style>